package net.borlis.sample.services.facade.ws.response;

import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author alex@borlis.net on 19.06.2014.
 */
@XmlRootElement
public class LifecycleResponseKey {

    private String keyName;

    public LifecycleResponseKey(String keyName) {
        this.keyName = keyName;
    }

    @XmlElement
    public String getKeyName() {
        return keyName;
    }

    //todo:: refactor equals/hashCode
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        LifecycleResponseKey that = (LifecycleResponseKey) o;

        if (keyName != null ? !keyName.equals(that.keyName) : that.keyName != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {

        return keyName != null ? keyName.hashCode() : 0;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("keyName", keyName).
                toString();
    }
}
